/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 * <p>
 * BaseFlowCheckItemService
 * 流程检查项
 * <p>
 * 修改纪录
 * 2021-01-12 版本：1.0 mengmeng 创建。
 *
 * @version 版本：1.0
 * @author 作者：mengmeng
 * 创建日期：2021-01-12
 */
package com.topscomm.base.service.impl;

import com.topscomm.base.BaseSystemConst;
import com.topscomm.base.pojo.BaseFlowCheckItemEntity;
import com.topscomm.base.service.IBaseFlowCheckItemService;
import com.topscomm.base.service.impl.auto.BaseFlowCheckItemServiceAuto;
import com.topscomm.basic.BasicEntity;
import com.topscomm.basic.util.PrimaryKeyUtil;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@Service(value = "baseFlowCheckItemService")
@Scope(value = "singleton")
public class BaseFlowCheckItemService extends BaseFlowCheckItemServiceAuto implements IBaseFlowCheckItemService {

    @Override
    protected void beforeInsert(BasicEntity entity) {
        super.beforeInsert(entity);
        if (entity.getId() <= 0) {// 赋值Id和单号
            long[] arrayId = PrimaryKeyUtil.GeneIDs(entity.getTableName(), 1);
            entity.setId(arrayId[0]);
            String code = String.valueOf(arrayId[0]);
            code = BaseSystemConst.BASE_FLOW_CHECK_ITEM_CODE_PREFIX + code.substring(0, 6) + code.substring(9);
            entity.setValue(BaseFlowCheckItemEntity.FieldCode, code);
        }
    }
}
